﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spun.Communications.Hosting;
using Spun.Controllers;
using Spun.Communications.Views;

namespace Spun.Communications
{
    public class Configuration<BC>
         where BC : IController, new()
    {
        public string MainView = "Main.view";

        public string ContentBaseURL = Constants.VirtualDirectories.CONTENT_SERVER;

        public string Host = "+";

        public short Port = 80;

        public string VirtualDirectory;

        public string BaseControllerName;

        public Terminal Create()
        {
            if (VirtualDirectory == null)
                throw new ArgumentNullException("VirtualDirectory");

            if (BaseControllerName == null)
                throw new ArgumentNullException("BaseControllerName");

            return new Terminal(Host, Port, VirtualDirectory, ContentBaseURL,
                new ApplicationContextFactory<BC>(BaseControllerName),
                new MainViewServer(MainView, ContentBaseURL));
        }
    }
}
